package tv.youxing;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;

import com.kymjs.rxvolley.RxVolley;
import com.kymjs.rxvolley.client.HttpCallback;
import com.kymjs.rxvolley.client.HttpParams;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import tv.youxing.android.R;
import tv.youxing.android.adapter.VideoAdapter;
import tv.youxing.android.entity.HomeModel;
import tv.youxing.android.ui.SubscribeDeteilsActivity;
import tv.youxing.android.utils.GsonUtils;
import tv.youxing.android.utils.StaticClass;

/**
 * 热门推荐
 */
public class MoreFeatureActivity extends Activity {

    @BindView(R.id.rv)
    GridView mGridView;
    private HomeModel allData;
    private List<HomeModel.ResultBean.PopularVideoBean.ContListBean> listDatas = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_more_hot);
        ButterKnife.bind(this);
        loadData();
    }


    void loadData(){

        HttpParams params = new HttpParams();

        RxVolley.post(StaticClass.home_module_more, params, new HttpCallback() {
            @Override
            public void onSuccess(String t) {
                allData = GsonUtils.GsonToBean(t,HomeModel.class);
                listDatas = allData.getResult().getPopular_video().getCont_list();
                mGridView.setAdapter(new VideoAdapter(MoreFeatureActivity.this,listDatas));
                mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                        Intent intent = new Intent(MoreFeatureActivity.this, SubscribeDeteilsActivity.class);
                        intent.putExtra("multimedia_id",listDatas.get(i).getMultimedia_id()+"");
                        startActivity(intent);
                    }
                });
            }
        });

    }
}
